package com.abc.scholarship.domain.entity;

import com.abc.scholarship.domain.dto.StudentImportDto;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import java.io.Serializable;
import java.math.BigDecimal;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

/**
 * <p>
 * 学生表
 * </p>
 *
 * @author LiJunXi
 * @since 2024-07-02
 */
@Data
@EqualsAndHashCode(callSuper = false)
@NoArgsConstructor
@TableName("tb_student")
public class Student implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 用户ID
     */
    @TableId("u_id")
    private Long uId;

    /**
     * 班级ID
     */
    @TableField("class_id")
    private Long classId;

    /**
     * 专业ID
     */
    @TableField("major_id")
    private Long majorId;

    /**
     * 学院ID
     */
    @TableField("college_id")
    private Long collegeId;

    /**
     * 绩点
     */
    @TableField("gpa")
    private BigDecimal gpa;

    /**
     * 加分绩点
     */
    @TableField("add_gpa")
    private BigDecimal addGpa;

    /**
     * 总绩点
     */
    @TableField("total_gpa")
    private BigDecimal totalGpa;

    /**
     * 班级名称
     */
    @TableField("class_name")
    private String className;

    /**
     * 专业名称
     */
    @TableField("major_name")
    private String majorName;

    /**
     * 学院名称
     */
    @TableField("college_name")
    private String collegeName;

    /**
     * 学生姓名
     */
    @TableField("u_name")
    private String uName;

    /**
     * 专业年级ID
     */
    @TableField("major_grade_id")
    private Long majorGradeId;

    public Student(Long uId, Long classId, Long majorId, Long collegeId, BigDecimal gpa, BigDecimal addGpa,
                   BigDecimal totalGpa, String className, String majorName, String collegeName, Long majorGradeId,
                   String uName) {
        this.uId = uId;
        this.classId = classId;
        this.majorId = majorId;
        this.collegeId = collegeId;
        this.gpa = gpa;
        this.addGpa = addGpa;
        this.totalGpa = totalGpa;
        this.className = className;
        this.majorName = majorName;
        this.collegeName = collegeName;
        this.majorGradeId = majorGradeId;
        this.uName = uName;
    }

    public static Student buildFromExcel(Clazz findClazz, Major findMajor, College findCollege, User findUser,
                                         StudentImportDto stuInfo, Long majorGradeId) {
        return new Student(findUser.getId(), findClazz.getId(), findMajor.getId(),
                findCollege.getId(), stuInfo.getGpa(), new BigDecimal(0), new BigDecimal(0),
                findClazz.getClassName(), findMajor.getMajorName(), findCollege.getCollegeName(),
                majorGradeId, findUser.getUName());
    }
}
